﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace CloudBlobMetadata
{
	/// <summary>
	/// Interaction logic for ExceptionDialog.xaml
	/// </summary>
	public partial class ExceptionDialog : Window
	{
		Exception m_ex;

		public ExceptionDialog(Exception ex)
		{
			InitializeComponent();

			treeView1.Items.Add(ExceptionToTVI(ex));
		}

		private TreeViewItem ExceptionToTVI(Exception ex, bool showCollapsed = true)
		{
			TreeViewItem tvi = new TreeViewItem();

			tvi.Header = ex.Message;

			if (showCollapsed)
			{
				tvi.IsExpanded = false;
			}

			if (null != ex.InnerException) {
				tvi.Items.Add(ExceptionToTVI(ex.InnerException));
			}

			return tvi;
		}
	}
}
